const CryptoJs = require("crypto-js")

const decrypt = function (url2, text2) {
    if ("string" != typeof url2)
        return;

    try {
        const str = encode(url2).repeat(3)
            , orgKey = str.slice(0, 16)
            , orgIv = str.slice(12, 28)
            , ikey = CryptoJs.enc.Utf8.parse(orgKey)
            , iiv = CryptoJs.enc.Utf8.parse(orgIv);

        return CryptoJs.AES.decrypt(text2, ikey, {
            iv: iiv,
            mode: CryptoJs.mode.CBC,
            padding: CryptoJs.pad.Pkcs7
        }).toString(CryptoJs.enc.Utf8)
    } catch (t) {
        console.log(t)
     }
};

function encode(str) {
    const encode22 = encodeURI(str);
    return btoa(encode22)
}
// console.log(decrypt("/api/author/search", text2))